package com.android.job.ui;

import com.android.job.fusion.FusionCode;
import com.android.job.logic.InterviewLogic;
import com.android.job.logic.LoginLogic;
import com.android.job.logic.RegisterLogic;
import com.android.job.logic.SearchJobLogic;
import com.android.job.logic.SearchResumeLogic;
import com.android.job.logic.SendResumeLogic;
import com.android.job.logic.UpdateVerLogic;
import com.android.job.util.json.JSONObject;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class TestIOActivity extends BaseActivity  implements OnClickListener
{
	private Button login ;
	private Button register;
	private Button interview;
	private Button send_resume;
	private Button search_job;
	private Button search_resume;
	private Button update_ver;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		 login = (Button) findViewById(R.id.login);
		 login.setText("登录");
		 login.setOnClickListener(this);
		 register = (Button) findViewById(R.id.register);
		 register.setText("注册");
		 register.setOnClickListener(this);
		 interview = (Button) findViewById(R.id.interview);
		 interview.setText("邀约面试");
		 interview.setOnClickListener(this);
		 send_resume = (Button) findViewById(R.id.send_resume);
		 send_resume.setText("发送简历");
		 send_resume.setOnClickListener(this);
		 search_job = (Button) findViewById(R.id.search_job);
		 search_job.setText("搜索职位");
		 search_job.setOnClickListener(this);
		 search_resume = (Button) findViewById(R.id.search_resume);
		 search_resume.setText("搜索人才");
		 search_resume.setOnClickListener(this);
		 update_ver = (Button) findViewById(R.id.update_ver);
		 update_ver.setText("检查更新");
		 update_ver.setOnClickListener(this);
	}

	@Override
	public void onClick(View view)
	{
		switch (view.getId())
		{
		case R.id.login:
			LoginLogic.getInstance().login(handler, "66178469-0", "123456");
			break;
		case R.id.register:
			RegisterLogic.getInstance().register(handler,  "123456", "3", "女", "320683198412134562", "6",  "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24");
			break;
		case R.id.interview:
			InterviewLogic.getInstance().interview(handler, "284", "232","744");
			break;
		case R.id.send_resume:
			SendResumeLogic.getInstance().sendResume(handler, "232", "284","744");
			break;
		case R.id.search_job:
			SearchJobLogic.getInstance().searchJob(handler, "", "320700", "", "", "", "");
			break;
		case R.id.search_resume:
			SearchResumeLogic.getInstance().searchResume(handler, "3", "", "", "", "", "0");
			break;
		case R.id.update_ver:
			UpdateVerLogic.getInstance().updateVer(handler, "1", "1");
			break;
		}
		
	}
	
	
	private Handler handler = new Handler()
	{

		public void handleMessage(Message msg)
		{
			switch (msg.what)
			{
				case FusionCode.NETWORK_ERROR:
					Toast.makeText(TestIOActivity.this, R.string.network_error,
							Toast.LENGTH_SHORT).show();
					break;
				case FusionCode.NETWORK_TIMEOUT_ERROR:
					Toast.makeText(TestIOActivity.this, R.string.network_timeout,
							Toast.LENGTH_SHORT).show();
					break;
				case FusionCode.RETURN_JSONOBJECT:
					JSONObject jsonObject =  (JSONObject) msg.obj;
					Log.e("free.lang","========="+jsonObject.toString());
					break;
			}

		};
	};

	
}
